package effect
{
	//图片滑动效果version 1.0
	
	import flash.display.MovieClip;
	import flash.display.Stage;
	public class Scale extends Effect
	{
		private var mc:MovieClip=new MovieClip();
		private var mystage:Stage;
		public function Scale(stage:Stage)
		{
			this.mystage=stage;
		}
		
		//图片放大
		public function ZoomPhotoX(array:Array):void
		{
			var mouseposition:Number = mystage.mouseX;
			var length:Number=array[0].width*array.length+super.distance*(array.length-1);
			if (mouseposition<0)
			{
				mouseposition=0;
			}
			if (mouseposition>length)
			{
				mouseposition=length;
			}
			for (var i:uint=0; i<array.length; i++)
			{
				var s:Number =super.max- Math.abs(mystage.mouseX - array[i].x)*super.ratio;//公式
				s = s < 1 ? 1 : s;
				array[i].scaleX = array[i].scaleY =s;
			}
			for (var j:uint=1; j<array.length; j++)
			{
				array[j].x = array[j-1].x + array[j-1].width/2 + array[j].width/2 + super.distance;
			}
		}
		//图片以y轴放大
		public function ZoomPhotoY(array:Array):void
		{
			var mouseposition:Number = mystage.mouseY;
			var length:Number=array[0].width*array.length+super.distance*(array.length-1);
			if (mouseposition<0)
			{
				mouseposition=0;
			}
			if (mouseposition>length)
			{
				mouseposition=length;
			}
			for (var i:uint=0; i<array.length; i++)
			{
				var s:Number =super.max- Math.abs(mystage.mouseY - array[i].y)*super.ratio;//公式
				s = s < 1 ? 1 : s;
				array[i].scaleX = array[i].scaleY =s;
			}
			for (var j:uint=1; j<array.length; j++)
			{
				array[j].y = array[j-1].y + array[j-1].height/2 + array[j].height/2 + super.distance;
			}
		}
		//还原
		public function RestPosition(array:Array,type:String="x"):void
		{
			for (var i:uint=0; i<array.length; i++)
			{
				array[i].scaleX =array[i].scaleY=1;
				if (type=="x")
				{
					array[i].x = array[0].width/2+i*(array[0].width + super.distance);
				} else
				{
					array[i].y = array[0].height/2+i*(array[0].height + super.distance);
				}
			}
		}
	}
}